package com.idanchuang.support.etcache.support.jetcache;

import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;

/**
 * @author yjy
 * Created at 2021/12/27 11:06 下午
 */
public class InEnvCondition extends SpringBootCondition {

    @Override
    public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {

        try {
            Class.forName("com.alicp.jetcache.autoconfigure.JetCacheCondition");
        } catch (ClassNotFoundException e) {
            return ConditionOutcome.noMatch("class [com.alicp.jetcache.autoconfigure.JetCacheCondition] not found");
        }
        try {
            Class.forName("com.alicp.jetcache.Cache");
        } catch (ClassNotFoundException e) {
            return ConditionOutcome.noMatch("class [com.alicp.jetcache.Cache] not found");
        }
        return ConditionOutcome.match();
    }


}